package com.sevntu.apvs.timeChart;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class Move extends Thread {
	private final JLabel text;
	private int x = 0;
	private int y = 0;

	public Move(JPanel myPanel, final String TEXT) 
	{
		super();
		text = new JLabel(TEXT);
		myPanel.add(text);
		text.setVisible(true);
		y = text.getY();
		start();
	}

	@Override
	public void run()
	{
		x = 400;
		for (;;)
		{
			if (x == 0)
			{
				try
				{
					Thread.sleep(5000);
				}
				catch (InterruptedException ex)
				{
					ex.printStackTrace();
				}
				x = text.getParent().getWidth();
			}
			text.setLocation(y + 10, x--);
			try 
			{
				Thread.sleep(30);
			}
			catch (InterruptedException e)
			{
				e.printStackTrace();
			}
		}
	}
} // class.